package com.project.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("listener")
public class ListenerController {

    @RequestMapping("session")
    public String testSession(HttpServletRequest request){
        HttpSession session = request.getSession();
        session.invalidate();
        return "ok";
    }

    @RequestMapping("dataChange")
    public String sessionDataChange(HttpServletRequest request){
        HttpSession session = request.getSession();
        int x = 9/0;

        session.setAttribute("one", "one");
        session.setAttribute("two", "two");

        session.removeAttribute("one");
        session.setAttribute("two", "aaa");

        return "ok";
    }
}
